package com.share.device.controller;

import com.share.common.core.web.controller.BaseController;
import com.share.common.core.web.domain.AjaxResult;
import com.share.common.core.web.page.TableDataInfo;
import com.share.common.log.annotation.Log;
import com.share.common.log.enums.BusinessType;
import com.share.common.security.annotation.RequiresPermissions;
import com.share.device.domain.Strategies;
import com.share.device.service.IStrategiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 策略信息Controller
 *
 * @author ruoyi
 * @date 2025-07-01
 */
@RestController
@RequestMapping("/strategies")
public class StrategiesController extends BaseController {
    @Autowired
    private IStrategiesService strategiesService;

    /**
     * 查询策略信息列表
     */
    @RequiresPermissions("device:strategies:list")
    @GetMapping("/list")
    public TableDataInfo list(Strategies strategies) {
        startPage();
        List<Strategies> list = strategiesService.selectStrategiesList(strategies);
        return getDataTable(list);
    }

    /**
     * 获取策略信息详细信息
     */
    @RequiresPermissions("device:strategies:query")
    @GetMapping(value = "/{strategyId}")
    public AjaxResult getInfo(@PathVariable("strategyId") Integer strategyId) {
        return AjaxResult.success(strategiesService.getById(strategyId));
    }

    /**
     * 新增策略信息
     */
    @RequiresPermissions("device:strategies:add")
    @Log(title = "策略信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Strategies strategies) {
        return toAjax(strategiesService.insertStrategies(strategies));
    }

    /**
     * 修改策略信息
     */
    @RequiresPermissions("device:strategies:edit")
    @Log(title = "策略信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Strategies strategies) {
        return toAjax(strategiesService.updateStrategies(strategies));
    }

    /**
     * 删除策略信息
     */
    @RequiresPermissions("device:strategies:remove")
    @Log(title = "策略信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{strategyIds}")
    public AjaxResult remove(@PathVariable Integer[] strategyIds) {
        return toAjax(strategiesService.deleteStrategiesByIds(strategyIds));
    }
} 